package com.example.hal.model;

import java.util.List;

import org.restlet.resource.ClientResource;

import android.util.Log;

import com.example.hal.model.Utilisateur;

public class DomaineController	{
	
	
	
	

	 public final ClientResource cr = new ClientResource(
	 EngineConfiguration.gae_path + "/rest/domaine");

	 public DomaineController() {
	 EngineConfiguration.getInstance();
	 }

	 public void create(Domaine d) throws Exception {
	 final DomaineControllerInterface uci = cr
	 .wrap(DomaineControllerInterface.class);

	 try {
	 uci.create(d);
	 Log.i("UtilisateurController", "Creation success !");
	 } catch (Exception e) {
	 Log.i("UtilisateurController", "Creation failed ! "+e.getMessage());
	 throw e;
	 }
	 }
	 
	 
	 public void update(Domaine domaine) throws Exception {
		 final DomaineControllerInterface uci = cr
		 .wrap(DomaineControllerInterface.class);

		 try {
		 uci.create(domaine);
		 Log.i("UtilisateurController", "update success !");
		 } catch (Exception e) {
		 Log.i("UtilisateurController", "update failed ! "+e.getMessage());
		 throw e;
		 }
		 }
	 
	 

	 public List<Domaine> getAllDomaine() throws Exception {
	 final DomaineControllerInterface uci = cr
	 .wrap(DomaineControllerInterface.class);
	 DomaineContainer content;
	 try{

		 content = uci.getAllDomaine();
		 Log.i("UtilisateurController", "getAllUtilisateurs success !");
	 }catch (Exception e) {
		 Log.i("UtilisateurController", "getAllUtilisateurs failed ! "+e.getMessage());
		 throw e;
		 }
	 return content.getDomaine_list();
	 }
	 
	 

	
	
}
